with GWindows.Common_controls; use GWindows.Common_Controls;
with GWindows.Buttons;         use GWindows.Buttons;
with GWindows.Windows;         use GWindows.Windows;
with GWindows.Windows.Main;    use GWindows.Windows.Main;
with GWindows.Panels;          use GWindows.Panels;
with GWindows.Edit_Boxes;      use GWindows.Edit_Boxes;
with GWindows.Menus;           use GWindows.Menus;
with GWindows.Base;

with constants;
with Config; use Config;
with GUI_Strings;

package GUI is
  type key_alarm_tab is record
    Alarm : aliased Window_Type;
    Chk   : Check_Box_Type;
    Edit  : Edit_Box_Type;
  end record;
  type key_alarm_tab_array is array (Positive range <>) of key_alarm_tab;

  type FFXIAlarm_Window_Type is record
    Top_Window : Main_Window_Type;
    Window     : Window_Type;

    StartStop : Button_Type;
    ViewLog   : Button_Type;

    Loop_Chk  : Check_Box_Type;
    Tell_Chk  : Check_Box_Type;
    LS_Chk    : Check_Box_Type;
    Party_Chk : Check_Box_Type;
    Say_Chk   : Check_Box_Type;
    Shout_Chk : Check_Box_Type;

    Key         : Group_Box_Type;
    Key_Pan     : Panel_Type;
    Tab_Control : Tab_Window_Control_Type;
    Key_Alarms  : key_alarm_tab_array(1..constants.Tabs);

    Menu   : Menu_Type;
    Status : Status_Bar_Type;
  end record;

  package Menu_Commands is
    MC_TELL      : constant := 1;
    MC_LINKSHELL : constant := 2;
    MC_PARTY     : constant := 3;
    MC_SAY       : constant := 4;
    MC_SHOUT     : constant := 5;
    --MC_KEYWORD   : constant := 6; -- Dropped.

    MC_LOOP      : constant := 7;
    MC_START     : constant := 8;

    MC_CLOSE     : constant := 9;
  end Menu_Commands;

  procedure Create_Window        (window : in out FFXIAlarm_Window_Type);
  -- Creates the main window with all its elements
  procedure Close_Window         (window : in out FFXIAlarm_Window_Type);
  -- Closes the main window (which causes the event loop to end) and destroys
  -- the system tray icon
  procedure Set_Status           (window : in out FFXIAlarm_Window_Type;
                                  msg    : in GWindows.GString);
  -- Sets a message at the status bar from the main window
  procedure Notify               (window : in out FFXIAlarm_Window_Type;
                                  notify : in GWindows.GString);
  --
  procedure Set_Stop             (window : in out FFXIAlarm_Window_Type;
                                  stopped : in boolean);
  -- Disables or enables the window components depending of the status of the
  -- program (stopped: components are enabled, started: components are disabled)
  procedure On_Edit              (window : in out FFXIAlarm_Window_Type;
                                  which  : in integer);
  -- To check the keyword enabling check_box when there is text on the editbox
  -- and uncheck it when there is no text
  procedure Minimize             (window : in out FFXIAlarm_Window_Type);
  -- Creates the System Tray Icon when the window is Minimized and hides the
  -- window
  procedure Maximize             (window : in out FFXIAlarm_Window_Type);
  -- Deletes the System Tray Icon and restores the window
  procedure Display_Tray_Menu    (window : in out FFXIAlarm_Window_Type;
                                  X : in integer;
                                  Y : in integer);
  -- Displays the menu designed for the system tray at the given coordinates,
  -- it retrieves the status of the checkboxes before being displayed
  procedure Process_Menu_Command (window : in out FFXIAlarm_Window_Type;
                                  cmd    : in integer);
  -- Modifies the checkboxes according to the selected menu command
  function  Retrieve_Config      (window : in FFXIAlarm_Window_Type)
                                  return config_type;
  procedure Enable               (Window  : in out FFXIAlarm_Window_Type;
                                  Enabled : in Boolean);
  -- Retrieves the settings from the window
  procedure Message_Box          (Window : in out FFXIAlarm_Window_Type;
                                  msg : in string);
  -- Displays a message box with the given message and disables the main window
  -- while the message box is being displayed
private
  procedure Set_Font (Window : in out GWindows.Base.Base_Window_Type'Class);
  function to_boolean (check_state : in check_state_type) return boolean;

  package Resources is
    Small_Icon : constant GWindows.GString := "#3";
    Large_Icon : constant GWindows.GString := "#4";
  end Resources;
end GUI;
